<template>
    <div id="I29" v-loading="loading_is">
        <el-row>
            <el-col :span="12">
                <span class="ititle">基础配置</span>


                <!-- 自动曝光 -->
                <div class="custom-heading">
                    自动曝光:&nbsp;&nbsp;&nbsp;
                    <input type="checkbox" v-model="I29.autoExposure" />&nbsp;&nbsp;
                    <span>启用自动曝光</span>
                </div>


                <!-- 曝光时间 -->
                <div class="custom-box" v-if="I29.autoExposure == false">曝光时间:&nbsp;&nbsp;&nbsp;
                    <button class="custom-button" @click="SetFixedExposure">
                        确定
                    </button>
                </div>
                <div class="custom-box" v-if="I29.autoExposure == false">

                    <div class="custom_list">
                        <label>
                            曝光时间(红)
                            <el-input type="number" v-model="I29.filter_state_red" />
                        </label>
                    </div>
                    <div class="custom_list">
                        <label>
                            曝光时间(绿)
                            <el-input type="number" v-model="I29.filter_state_green" />
                        </label>
                    </div>
                    <div class="custom_list">
                        <label>
                            曝光时间(蓝)
                            <el-input type="number" v-model="I29.filter_state_blue" />
                        </label>
                    </div>
                    <div class="custom_list">
                        <label>
                            曝光时间(xb)
                            <el-input type="number" v-model="I29.filter_state_xb" />
                        </label>
                    </div>

                </div>
                <!-- 滤片状态 -->
                <div class="custom-heading">滤片状态：</div>
                <div class="custom-box">
                    <label>
                        <input type="checkbox" v-model="is_filter_state_red" />
                        {{ filterStatus[0] }}
                    </label>
                    <label>
                        <input type="checkbox" v-model="is_filter_state_green" />
                        {{ filterStatus[1] }}
                    </label>
                    <label>
                        <input type="checkbox" v-model="is_filter_state_blue" />
                        {{ filterStatus[2] }}
                    </label>
                    <label>
                        <input type="checkbox" v-model="is_filter_state_xx" />
                        {{ filterStatus[3] }}
                    </label>
                </div>

                <!-- 焦距 -->
                <div class="custom-heading">焦距：</div>
                <div class="custom-box">
                    <table style="margin-bottom: 15px;">
                        <tr>
                            <td>
                                <button class="custom-button" @click="adjustValue(-1)">-1</button>
                            </td>
                            <td>
                                <button class="custom-button" @click="adjustValue(-0.1)">-0.1</button>
                            </td>
                            <td>
                                <button class="custom-button" @click="adjustValue(-0.01)">-0.01</button>
                            </td>

                            <td>
                                <el-input type="number" v-model="I29.focus_distance" step="0.01" min="0"></el-input>
                            </td>
                            <td>
                                <button class="custom-button" @click="adjustValue(0.01)">+0.01</button>
                            </td>
                            <td>
                                <button class="custom-button" @click="adjustValue(0.1)">+0.1</button>
                            </td>
                            <td>
                                <button class="custom-button" @click="adjustValue(1)">+1</button>
                            </td>
                        </tr>
                    </table>
                </div>

                <div class="custom-box">
                    <!-- 光圈 -->
                    <div class="custom_list">&nbsp;光&nbsp;&nbsp;&nbsp;&nbsp;圈&nbsp;&nbsp;:&nbsp;&nbsp;
                        <el-select v-model="I29.aperture" class="el-input__count-inner">
                            <el-option v-for="item in GetApertureFNumber" :key="item" :label="item" :value="item"
                                class="inner">
                            </el-option>
                        </el-select>
                    </div>

                    <div class="custom_list">颜色校准:&nbsp;&nbsp;&nbsp;<el-select v-model="I29.color_calibration_value">
                            <el-option v-for="item in GetColorCalibration" :key="item" :label="item" :value="item">
                            </el-option>
                        </el-select>
                    </div>

                    <div class="custom_list">校准文件:&nbsp;&nbsp;
                        <el-select v-model="I29.txt">
                            <el-option v-for="item in txt_type" :key="item" :label="item" :value="item">
                            </el-option>
                        </el-select>
                    </div>


                    <!-- 色偏校准 -->
                    <div class="custom_list">色偏校准:&nbsp;&nbsp;&nbsp;<el-select
                            v-model="I29.color_shiftCorrection_value">
                            <el-option v-for="item in ColorShiftCorrection" :key="item" :label="item" :value="item">
                            </el-option>
                        </el-select>
                    </div>
                    <!-- 均匀场校准 -->
                    <div class="custom_list">均&nbsp;匀&nbsp;场&nbsp;校&nbsp;准:&nbsp;&nbsp;&nbsp;
                        <el-select v-model="I29.homogeneous_field">
                            <el-option v-for="item in GetFlatField" :key="item" :label="item" :value="item">
                            </el-option>
                        </el-select>
                    </div>

                    <div class="custom_list">灰度&nbsp;或&nbsp;color&nbsp;:&nbsp;&nbsp;
                        <el-select v-model="is_color" class="el-input__count-inner">
                            <el-option v-for="(item, key) in ColorOrGrey" :key="item" :label="key" :value="item"
                                class="inner">
                                {{ key }}
                            </el-option>
                        </el-select>
                    </div>

                    <!-- 图像标尺校准 -->
                    <div class="custom_list">图像标尺校准:&nbsp;&nbsp;&nbsp;
                        <el-select v-model="I29.image_rulers">
                            <el-option v-for="item in GetImageScaling" :key="item" :label="item" :value="item">
                            </el-option>
                        </el-select>
                    </div>

                </div>
            </el-col>
            <el-col :span="12">
                <span class="ititle">高级配置</span>

                <div class="custom-heading">曝光限制类型:&nbsp;&nbsp;&nbsp;
                    <el-select v-model="I29.SetExposureLimit_id">
                        <el-option v-for="item in SetExposureLimit" :key="item" :label="item" :value="item">
                            {{ item.valueOf() }}
                        </el-option>
                    </el-select>
                </div>
                <div class="custom-heading"> 锥光镜头校准:&nbsp;&nbsp;&nbsp;
                    <el-select v-model="GetConoscopeCurrentValues">
                        <el-option v-for="item in GetConoscope" :key="item" :label="item" :value="item">
                        </el-option>
                    </el-select>
                </div>

                <span class="ititle">图片保存配置</span>


                <!-- 测量设置 -->
                <div class="custom-box">
                    <div class="custom_list">pLeft:&nbsp;&nbsp;&nbsp;
                        <el-input placeholder="请输入内容" v-model="FrameRegion.pLeft" :disabled="true" >

                        </el-input>
                    </div>

                    <div class="custom_list">pTop:&nbsp;&nbsp;&nbsp;
                        <el-input placeholder="请输入内容" v-model="FrameRegion.pTop" :disabled="true" >
                        </el-input>
                    </div>
                    <div class="custom_list">pWidth:&nbsp;&nbsp;&nbsp;
                        <el-input placeholder="请输入内容" v-model="FrameRegion.pWidth" :disabled="true" >
                        </el-input>
                    </div>
                    <div class="custom_list">pHeight:&nbsp;&nbsp;&nbsp;
                        <el-input placeholder="请输入内容" v-model="FrameRegion.pHeight" :disabled="true" >
                        </el-input>
                    </div>
                    <!-- 实时图像 -->
                    <div class="custom_list">
                        <span>截图设置:&nbsp;&nbsp;&nbsp;</span>
                        <button class="custom-button" 
                            @click="ShowSubFrameDialog">开启</button>
                    </div>
                    <div class="custom_list" >
                        <span>实时图像:&nbsp;&nbsp;&nbsp;</span>
                        <button class="custom-button" @click="ImageStart">开启</button>
                    </div>

                    <div class="custom_list">测量设置:&nbsp;&nbsp;&nbsp;
                        <button class="custom-button" @click="is_address = true">启用测量</button>
                    </div>
                    <!-- 新增配置 -->
                    <div class="custom_list">新增配置:&nbsp;&nbsp;&nbsp;
                        <button class="custom-button" @click="createI29">
                            新增配置
                        </button>
                    </div>
                </div>


                <span class="custom-heading">图片保存路径:{{ save_file.url }}\{{
                    save_file.savefileone
                }}</span>
                <div>
                    <button
                        style="font-size: 20px; width: 200px;height: 50px; margin-left:0%;background-color: #FF0000; color: white;"
                        @click="BreakList">断开亮度计
                    </button>
                    <button
                        style="font-size: 20px; width: 200px;height: 50px; margin-left:0%;background-color: #FF0000; color: white;"
                        @click="ConnectList">连接亮度计
                    </button>


                </div>

            </el-col>


        </el-row>


        <!--    新增配置-->
        <el-dialog title="添加I29配置" :visible.sync="is_createI29" width="30%" :before-close="handleClose_is_createI29">
            <el-form>
                <el-form-item label="配置名称:" :label-width="formLabelWidth">
                    <el-input v-model="I29.name_file"></el-input>
                </el-form-item>
                <el-form-item label="焦距距离:" :label-width="formLabelWidth">
                    <el-input v-model="I29.focus_distance"></el-input>
                </el-form-item>
                <el-form-item label="光圈:" :label-width="formLabelWidth">
                    <el-select v-model="I29.aperture">
                        <el-option v-for="item in GetApertureFNumber" :key="item" :label="item" :value="item">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="颜色矫正:" :label-width="formLabelWidth">
                    <el-select v-model="I29.color_calibration_value">
                        <el-option v-for="item in GetColorCalibration" :key="item" :label="item" :value="item">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="色偏矫正:" :label-width="formLabelWidth">
                    <el-select v-model="I29.color_shiftCorrection_value">
                        <el-option v-for="item in ColorShiftCorrection" :key="item" :label="item" :value="item">
                        </el-option>
                    </el-select>
                </el-form-item>

                <el-form-item label="校准文件:" :label-width="formLabelWidth">
                    <el-select v-model="I29.txt">
                        <el-option v-for="item in txt_type" :key="item" :label="item" :value="item">
                        </el-option>
                    </el-select>
                </el-form-item>

                <el-form-item label="滤光片(红):" :label-width="formLabelWidth">
                    <el-select v-model="is_filter_state_red">
                        <el-option v-for="item in is_exposure_value" :key="item.values" :label="item.values"
                            :value="item.values">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="滤光片(绿):" :label-width="formLabelWidth">
                    <el-select v-model="is_filter_state_green">
                        <el-option v-for="item in is_exposure_value" :key="item.values" :label="item.values"
                            :value="item.values">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="滤光片(蓝):" :label-width="formLabelWidth">
                    <el-select v-model="is_filter_state_blue">
                        <el-option v-for="item in is_exposure_value" :key="item.values" :label="item.values"
                            :value="item.values">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="滤光片(XB):" :label-width="formLabelWidth">
                    <el-select v-model="is_filter_state_xx">
                        <el-option v-for="item in is_exposure_value" :key="item.values" :label="item.values"
                            :value="item.values">
                        </el-option>
                    </el-select>
                </el-form-item>


                <el-form-item label="均匀场校准:" :label-width="formLabelWidth">
                    <el-select v-model="I29.homogeneous_field">
                        <el-option v-for="item in GetFlatField" :key="item" :label="item" :value="item">
                        </el-option>
                    </el-select>
                </el-form-item>

                <el-form-item label="灰度或color:" :label-width="formLabelWidth">
                    <el-select v-model="is_color" class="el-input__count-inner">
                        <el-option v-for="(item, key) in ColorOrGrey" :key="item" :label="key" :value="item"
                            class="inner">
                            {{ key }}
                        </el-option>
                    </el-select>
                </el-form-item>

                <el-form-item label="图像标尺校准:" :label-width="formLabelWidth">
                    <el-select v-model="I29.image_rulers">
                        <el-option v-for="item in GetImageScaling" :key="item" :label="item" :value="item">
                        </el-option>
                    </el-select>
                </el-form-item>

                <el-form-item label="曝光限制类型:" :label-width="formLabelWidth">
                    <el-select v-model="I29.SetExposureLimit_id">
                        <el-option v-for="item in SetExposureLimit" :key="item" :label="item" :value="item">
                            {{ item.valueOf() }}
                        </el-option>
                    </el-select>
                </el-form-item>

                <el-form-item label="锥光镜头校准:" :label-width="formLabelWidth">
                    <el-select v-model="GetConoscopeCurrentValues">
                        <el-option v-for="item in GetConoscope" :key="item" :label="item" :value="item">
                        </el-option>
                    </el-select>
                </el-form-item>

                <el-form-item label="是否是自动曝光:" :label-width="formLabelWidth">
                    <el-select v-model="I29.autoExposure">
                        <el-option v-for="item in is_exposure_value" :key="item.values" :label="item.values"
                            :value="item.values">
                        </el-option>
                    </el-select>
                    <!--          <el-input v-model="this.I29.is_exposure"></el-input>-->
                </el-form-item>
                <!--        <el-form-item label="曝光时间:" :label-width="formLabelWidth" v-if="I29.is_exposure === false">-->
                <!--          &lt;!&ndash;        <el-form-item label="曝光时间:" :label-width="formLabelWidth">&ndash;&gt;-->
                <!--          <el-input v-model="I29.exposure_time"></el-input>-->
                <!--        </el-form-item>-->
                <div v-if="I29.autoExposure === false">
                    <el-form-item label="曝光时间(红)(0-255):" :label-width="formLabelWidth">
                        <el-input v-model="I29.filter_state_red"></el-input>
                    </el-form-item>
                    <el-form-item label="曝光时间(绿)(0-255):" :label-width="formLabelWidth">
                        <el-input v-model="I29.filter_state_green"></el-input>
                    </el-form-item>
                    <el-form-item label="曝光时间(蓝)(0-255):" :label-width="formLabelWidth">
                        <el-input v-model="I29.filter_state_blue"></el-input>
                    </el-form-item>
                    <el-form-item label="曝光时间(xb)(0-255):" :label-width="formLabelWidth">
                        <el-input v-model="I29.filter_state_xb"></el-input>
                    </el-form-item>
                </div>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="is_createI29 = false">取 消</el-button>
                <el-button type="primary" @click="createI29_one">确 定</el-button>
            </div>
        </el-dialog>
        <el-dialog v-loading="loading" element-loading-text="正在保存图片中" element-loading-spinner="el-icon-loading"
            element-loading-background="rgba(0, 0, 0, 0.8)" title="测试项名称" :visible.sync="is_address" width="30%"
            :before-close="handleClose_is_address">
            <el-form>
                <el-form-item label="图片名:" :label-width="formLabelWidth">
                    <el-input v-model="address"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="is_address = false">取 消</el-button>
                <el-button type="primary" @click="GetmMasurementEnabled">确 定</el-button>
            </div>
        </el-dialog>

    </div>
</template>

<script>
export default {
    created() {
        this.GetColorShiftCorrection()
        this.GetColorCalibrationID()
        this.GetAperture()
        this.GetMeasurementSetupList()
        this.GetCaptureFilterState()
        this.GetExposureLimitId()
        this.GetSubFrameRegion()
        this.savefile()
    },
    data() {
        return {
            save_file: "",
            FrameRegion: { 'pLeft': 0, 'pTop': 0, 'pWidth': 0, 'pHeight': 0 },
            loading_is: false,
            is_color: 'true',
            ColorOrGrey: { 'color': 'false', '辉度': 'true' },
            loading: false,
            is_address: false,
            address: '',
            // 滤光片
            is_filter_state_red: false,
            is_filter_state_green: false,
            is_filter_state_blue: false,
            is_filter_state_xx: false,
            filter_state_red: '',
            filter_state_green: '',
            filter_state_blue: '',
            filter_state_xb: '',
            // 测量设置
            measurementEnabled: false,

            // 自动曝光
            autoExposure: false,

            // 曝光时间
            exposureTimes: [10, 20, 30, 40],
            selectedExposure: null,

            // 滤片状态
            filterStatus: ['滤光片(红)', '滤光片(绿)', '滤光片(蓝)', '滤光片(XB)'],
            selectedFilter: null,

            // 焦距
            focalLength: null,

            // 光圈
            aperture: null,

            // 锥光镜头校准
            coneCalibration: false,

            // 颜色校准
            colorCalibration: false,

            // 色偏校准
            colorShiftCalibration: false,

            // 图像标尺校准
            rulerCalibration: false,

            // 均匀场校准
            uniformFieldCalibration: false,

            // 实时图像
            liveImage: null,
            is_createI29: false,
            formLabelWidth: "120",
            I29: {
                txt: '灰度校准文件',
                autoExposure: false,
                SetExposureLimit_id: '',
                SetExposureLimit_value: '',
                name_file: '',
                is_exposure: '',
                exposure_time: '',
                is_filter_state_red: '',
                is_filter_state_green: '',
                is_filter_state_blue: '',
                is_filter_state_xb: '',
                filter_state_red: '',
                filter_state_green: '',
                filter_state_blue: '',
                filter_state_xb: '',
                focus_distance: '',
                aperture: '',
                color_calibration_id: '',
                color_calibration_value: '',
                color_shiftCorrection_id: '',
                color_shiftCorrection_value: '',
                image_rulers: '',
                homogeneous_field: '',
            },
            is_exposure_value: [{ id: '1', values: true },
            { id: '2', values: false }],
            ColorShiftCorrection: '',
            ColorShiftID: '',
            ColorShiftValues: '',
            GetColorCalibration: '',
            GetColorID: '',
            GetColorValues: '',
            GetApertureFNumber: '',
            GetApertureFNumberID: '',
            GetApertureFNumberValues: '',
            GetExposureTime: '',
            FILTER_TYPE_Y_GREEN: '',
            FILTER_TYPE_X_RED: '',
            FILTER_TYPE_Z_BLUE: '',
            FILTER_TYPE_XB: '',
            IS_FILTER_TYPE_Y_GREEN: '',
            IS_FILTER_TYPE_X_RED: '',
            IS_FILTER_TYPE_Z_BLUE: '',
            IS_FILTER_TYPE_XB: '',
            LensFocalLengthMin: '',
            LensFocalLengthMax: '',
            GetLensFocalLength: '',
            GetConoscope: '',
            GetConoscopeCurrent: '',
            GetConoscopeCurrentValues: '',
            GetImageScaling: '',
            SetExposureLimit: {
                1: '标准模式',
                2: '亮点模式',
                3: '亮点模式2*2',
                4: '亮点模式3*3',
                5: '亮点模式4*4',
            },
            GetImageScalingID: '',
            GetImageScalingID2: '',
            GetFlatField: '',
            GetFlatFieldId: '',
            GetFlatFieldValues: '',
            GetAutoAdjust: '',
            txt_type: ['色彩还原亮度文件', '灰度校准文件']
        };
    },
    mounted() {

        this.$watch('I29.color_shiftCorrection_value', (newValue, oldValue) => {
            let selectedKey = null;

            for (let key in this.ColorShiftCorrection) {
                if (this.ColorShiftCorrection[key] === newValue) {
                    this.ColorShiftID = key
                    selectedKey = key;
                    break; // 找到后立即终止循环
                }
            }

            if (selectedKey !== null) {
                this.$axios.post(this.$settings.BASE_URL_CMS + 'CMS-KM/Brightness/SetColorShift/', { 'id': selectedKey }).then((res) => {
                    if (res.data.code == 100) {
                        this.$notify({
                            title: res.data.msg,
                            type: 'success'
                        });
                    } else {
                        this.$notify.error({ title: res.data.msg });
                    }
                });
            } else {
                // 如果找不到对应的键
                return null;
            }
        });
        this.$watch('I29.color_calibration_value', (newValue, oldValue) => {
            let selectedKey = null;

            for (let key in this.GetColorCalibration) {
                if (this.GetColorCalibration[key] === newValue) {
                    this.GetColorID = key
                    selectedKey = key;
                    break; // 找到后立即终止循环
                }
            }

            if (selectedKey !== null) {
                this.$axios.post(this.$settings.BASE_URL_CMS + 'CMS-KM/Brightness/SetColorCalibration/', { 'id': selectedKey }).then((res) => {
                    if (res.data.code == 100) {
                        this.$notify({
                            title: res.data.msg,
                            type: 'success'
                        });
                    } else {
                        this.$notify.error({ title: res.data.msg });
                    }
                });
            } else {
                // 如果找不到对应的键
                return null;
            }
        });

        this.$watch('I29.aperture', (newValue, oldValue) => {
            console.log('莫名奇妙执行')
            this.$axios.post(this.$settings.BASE_URL_CMS + 'CMS-KM/Brightness/SetAperture/', { 'value': newValue }).then((res) => {
                if (res.data.code == 100) {
                    this.$notify({
                        title: res.data.msg,
                        type: 'success'
                    });
                } else {
                    this.$notify.error({ title: res.data.msg });
                }
            })
        });
        this.$watch('GetConoscopeCurrentValues', (newValue, oldValue) => {


            let selectedKey = null;

            for (let key in this.GetConoscope) {
                if (this.GetConoscope[key] === newValue) {
                    this.GetConoscopeCurrent = key
                    selectedKey = key;
                    break; // 找到后立即终止循环
                }
            }
            console.log(selectedKey, selectedKey == 2);
            if (selectedKey == 2) {
                this.loading_is = true
            }
            if (selectedKey !== null) {
                this.$axios.post(this.$settings.BASE_URL_CMS + 'CMS-KM/Brightness/SetCONOScope/', { 'value': selectedKey }).then((res) => {
                    if (res.data.code == 100) {

                        this.loading_is = false
                        this.$notify({
                            title: res.data.msg,
                            type: 'success'
                        });


                    } else {
                        this.$notify.error({ title: res.data.msg });
                    }
                });
            } else {
                // 如果找不到对应的键
                return null;
            }
        });
        this.$watch('I29.SetExposureLimit_id', (newValue, oldValue) => {
            let selectedKey = null;
            console.log(newValue)
            for (let key in this.SetExposureLimit) {
                console.log(key)
                console.log(this.SetExposureLimit[key])
                console.log(this.SetExposureLimit[key] === newValue)
                if (this.SetExposureLimit[key] === newValue) {
                    this.GetImageScalingID = key
                    selectedKey = key;
                    break; // 找到后立即终止循环
                }
            }
            console.log(selectedKey)
            if (selectedKey !== null) {
                this.$axios.post(this.$settings.BASE_URL_CMS + 'CMS-KM/Brightness/SetExposure/', { 'id': selectedKey }).then((res) => {
                    if (res.data.code == 100) {
                        this.$notify({
                            title: res.data.msg,
                            type: 'success'
                        });
                    } else {
                        this.$notify.error({ title: res.data.msg });
                    }
                });
            } else {
                // 如果找不到对应的键
                return null;
            }
        });
        this.$watch('I29.image_rulers', (newValue, oldValue) => {
            let selectedKey = null;

            for (let key in this.GetImageScaling) {
                if (this.GetImageScaling[key] === newValue) {
                    this.GetImageScalingID2 = key
                    selectedKey = key;
                    break; // 找到后立即终止循环
                }
            }
            console.log(selectedKey)
            if (selectedKey !== null) {
                this.$axios.post(this.$settings.BASE_URL_CMS + 'CMS-KM/Brightness/SetImageScalingCalibration/', { 'id': selectedKey }).then((res) => {
                    if (res.data.code == 100) {
                        this.$notify({
                            title: res.data.msg,
                            type: 'success'
                        });
                    } else {
                        this.$notify.error({ title: res.data.msg });
                    }
                });
            } else {
                // 如果找不到对应的键
                return null;
            }
        });


        this.$watch('I29.homogeneous_field', (newValue, oldValue) => {
            let selectedKey = null;

            for (let key in this.GetFlatField) {
                if (this.GetFlatField[key] === newValue) {
                    this.GetFlatFieldId = key
                    selectedKey = key;
                    break; // 找到后立即终止循环
                }
            }

            if (selectedKey !== null) {
                this.$axios.post(this.$settings.BASE_URL_CMS + 'CMS-KM/Brightness/SetFlatField/', { 'id': selectedKey }).then((res) => {
                    if (res.data.code == 100) {
                        this.$notify({
                            title: res.data.msg,
                            type: 'success'
                        });
                    } else {
                        this.$notify.error({ title: res.data.msg });
                    }
                });
            } else {
                // 如果找不到对应的键
                return null;
            }
        });
        this.$watch('I29.focus_distance', (newValue, oldValue) => {
            this.$axios.post(this.$settings.BASE_URL_CMS + 'CMS-KM/Brightness/SetLensFocus/', { 'focal': parseFloat(newValue) }).then((res) => {
                if (res.data.code == 100) {
                    this.$notify({
                        title: res.data.msg,
                        type: 'success'
                    });
                } else {
                    this.$notify.error({ title: res.data.msg });
                }
            })
        });
        this.$watch('I29.autoExposure', (newValue, oldValue) => {
            this.$axios.post(this.$settings.BASE_URL_CMS + 'CMS-KM/Brightness/SetAutoAdjust/', { 'values': newValue }).then((res) => {
                if (res.data.code == 100) {
                    this.$notify({
                        title: res.data.msg,
                        type: 'success'
                    });
                } else {
                    this.$notify.error({ title: res.data.msg });
                }
            })
        });
        this.$watch('is_filter_state_red', (newValue, oldValue) => {

            this.$axios.post(this.$settings.BASE_URL_CMS + 'CMS-KM/Brightness/SetCapture/', {
                'red': this.is_filter_state_red,
                'green': this.is_filter_state_green,
                'blue': this.is_filter_state_blue,
                'xb': this.is_filter_state_xx
            }).then((res) => {
                if (res.data.code == 100) {
                    this.$notify({
                        title: res.data.msg,
                        type: 'success'
                    });
                } else {
                    this.$notify.error({ title: res.data.msg });
                }
            })
        });
        this.$watch('is_filter_state_green', (newValue, oldValue) => {

            this.$axios.post(this.$settings.BASE_URL_CMS + 'CMS-KM/Brightness/SetCapture/', {
                'red': this.is_filter_state_red,
                'green': this.is_filter_state_green,
                'blue': this.is_filter_state_blue,
                'xb': this.is_filter_state_xx
            }).then((res) => {
                if (res.data.code == 100) {
                    this.$notify({
                        title: res.data.msg,
                        type: 'success'
                    });
                } else {
                    this.$notify.error({ title: res.data.msg });
                }
            })
        })
        this.$watch('is_filter_state_blue', (newValue, oldValue) => {
            this.$axios.post(this.$settings.BASE_URL_CMS + 'CMS-KM/Brightness/SetCapture/', {
                'red': this.is_filter_state_red,
                'green': this.is_filter_state_green,
                'blue': this.is_filter_state_blue,
                'xb': this.is_filter_state_xx
            }).then((res) => {
                if (res.data.code == 100) {
                    this.$notify({
                        title: res.data.msg,
                        type: 'success'
                    });
                } else {
                    this.$notify.error({ title: res.data.msg });
                }
            })
        })
        this.$watch('is_filter_state_xx', (newValue, oldValue) => {
            this.$axios.post(this.$settings.BASE_URL_CMS + 'CMS-KM/Brightness/SetCapture/', {
                'red': this.is_filter_state_red,
                'green': this.is_filter_state_green,
                'blue': this.is_filter_state_blue,
                'xb': this.is_filter_state_xx
            }).then((res) => {
                if (res.data.code == 100) {
                    this.$notify({
                        title: res.data.msg,
                        type: 'success'
                    });
                } else {
                    this.$notify.error({ title: res.data.msg });
                }
            })
        })

    }
    ,


    methods: {
        savefile() {
            this.$axios
                .get(this.$settings.BASE_URL_CMS + `CMS-Task/savefiles/`)
                .then((res) => {
                    if (res.data.code == 100) {
                        console.log(res.data.data);
                        this.save_file = res.data.data[0];
                    }
                });
        },
        // 连接亮度计
        ConnectList() {
            this.$axios.get(this.$settings.BASE_URL_CMS + `CMS-KM/Brightness/Connect/`).then((res) => {
                if (res.data.code === 100) {
                    this.$notify({
                        title: res.data.msg,
                        type: 'success'
                    });
                } else {
                    this.$notify.error({ title: res.data.msg });
                }
            })
        },
        BreakList() {
            this.$axios.get(this.$settings.BASE_URL_CMS + `CMS-KM/Brightness/Device/`).then((res) => {
                if (res.data.code === 100) {
                    this.$notify({
                        title: res.data.msg,
                        type: 'success'
                    });
                } else {
                    this.$notify.error({ title: res.data.msg });
                }
            })
        },
        // 焦距修改
        adjustValue(value) {
            this.I29.focus_distance = parseFloat((parseFloat(this.I29.focus_distance) + value).toFixed(2));
        },

        // 修改色偏校准
        SetColorShiftCorrection() {
            console.log('SetColorShiftCorrection 函数被调用了');
            console.log(this.I29.color_shiftCorrection_value)
        }
        ,
        // 获取截图参数
        GetSubFrameRegion() {
            this.$axios.get(this.$settings.BASE_URL_CMS + 'CMS-KM/Brightness/GetSubFrame/').then((res) => {
                if (res.data.code == 100) {
                    this.FrameRegion = res.data.data
                }
            })
        },
        // 截图设置
        ShowSubFrameDialog() {
            this.$axios.get(this.$settings.BASE_URL_CMS + 'CMS-KM/Brightness/ShowSubFrame/').then((res) => {
                if (res.data.code == 100) {
                    this.GetSubFrameRegion()
                    this.$notify({
                        title: res.data.msg,
                        type: 'success'
                    });
                }
            })
        },

        // 实时图像
        ImageStart() {
            this.$axios.get(this.$settings.BASE_URL_CMS + 'CMS-KM/Brightness/ShowFocusMode/').then((res) => {
                if (res.data.code == 100) {
                    this.GetLensFocusDistance()
                    this.GetAperture()
                    this.$notify({
                        title: res.data.msg,
                        type: 'success'
                    });
                } else {
                    this.$notify.error({ title: res.data.msg });
                }
            })
        },
        SetLensFocusDistance() {
            this.$axios.post(this.$settings.BASE_URL_CMS + 'CMS-KM/Brightness/SetLensFocus/', { 'focal': parseFloat(this.I29.focus_distance) }).then((res) => {
                if (res.data.code == 100) {
                    this.$notify({
                        title: res.data.msg,
                        type: 'success'
                    });
                } else {
                    this.$notify.error({ title: res.data.msg });
                }
            })
        }
        ,

        GetmMasurementEnabled() {
            this.loading = true
            this.$axios.post(this.$settings.BASE_URL_CMS + 'CMS-KM/Brightness/SaveImageOrTxt/', {
                'address': this.address,
                'is_color': this.is_color,
                'txt_type': this.I29.txt
            }).then((res) => {
                if (res.data.code == 100) {
                    this.loading = false
                    this.GetExposureTimeTrue()
                    this.is_address = false
                    this.$notify({
                        title: res.data.msg,
                        type: 'success'
                    });
                } else {
                    this.$notify.error({ title: res.data.msg });
                }

            })
        }
        ,
        SetFixedExposure() {
            // 设置固定曝光时间
            this.$axios.post(this.$settings.BASE_URL_CMS + 'CMS-KM/Brightness/SetFixedExposureTime/', {
                'red': this.I29.filter_state_red,
                'green': this.I29.filter_state_green,
                'blue': this.I29.filter_state_blue,
                'xb': this.I29.filter_state_xb
            }).then((res) => {
                if (res.data.code == 100) {
                    this.$notify({
                        title: res.data.msg,
                        type: 'success'
                    });
                } else {
                    this.$notify.error({ title: res.data.msg });
                }
            })
        }
        ,
        SetautoExposure() {
            // 设置自动曝光
            console.log(this.I29.autoExposure)
            this.$axios.get(this.$settings.BASE_URL_CMS + 'brightness_auto/setautoexposure/' + `?values=${this.I29.autoExposure}`).then((res) => {
                if (res.data.code == 100) {
                    this.$notify({
                        title: res.data.msg,
                        type: 'success'
                    });
                } else {
                    this.$notify.error({ title: res.data.msg });
                }
            })
        }
        ,
        GetColorShiftCorrectionList() {
            this.$axios.get(this.$settings.BASE_URL_CMS + 'CMS-KM/Brightness/GetColorShiftCorrection/').then((res) => {
                if (res.data.code == 100) {
                    this.ColorShiftCorrection = res.data.data
                    this.ColorShiftValues = res.data.data[this.ColorShiftID]
                    this.I29.color_shiftCorrection_value = res.data.data[this.ColorShiftID]
                }
            })
        }
        ,
        // 获取当前色偏校准模式的id
        GetColorShiftCorrection() {
            this.$axios.get(this.$settings.BASE_URL_CMS + 'CMS-KM/Brightness/GetColorShiftCorrectionNumber/').then((res) => {
                if (res.data.code == 100) {
                    this.ColorShiftID = res.data.data
                    this.GetColorShiftCorrectionList()
                }
            })
        }
        ,
        // 获取设备颜色校准模式信息(不要单独调用)
        GetColorCalibrationList() {
            this.$axios.get(this.$settings.BASE_URL_CMS + 'CMS-KM/Brightness/GetColorCalibration/').then((res) => {
                if (res.data.code == 100) {
                    console.log(res.data.data)
                    // console.log(res.data.data[this.GetColorID],898989)
                    this.GetColorCalibration = res.data.data
                    // this.GetColorValues = res.data.data[this.GetColorID]
                    // this.I29.color_calibration_id = res.data.data[this.GetColorID]
                    // this.I29.this.ColorShiftID = res.data.data[this.GetColorID]
                }
            })
        }
        ,
        // 获取当前颜色校准模式的id
        GetColorCalibrationID() {
            this.$axios.get(this.$settings.BASE_URL_CMS + 'CMS-KM/Brightness/GetColorCalibrationNumber/').then((res) => {
                if (res.data.code == 100) {
                    console.log(res.data.data, 90909)
                    this.GetColorID = res.data.data
                    this.I29.color_calibration_value = res.data.data
                    this.GetColorCalibrationList()
                }
            })
        }
        ,
        // 获取设备光圈的信息列表
        GetApertureFNumberList() {
            this.$axios.get(this.$settings.BASE_URL_CMS + 'CMS-KM/Brightness/GetAperture/').then((res) => {
                if (res.data.code == 100) {
                    console.log(res.data.data, 2322)
                    this.GetApertureFNumber = res.data.data.data
                    this.GetApertureFNumberValues = res.data.data.data
                }
            })
        }
        ,
        // 获取设备当前的光圈的值
        GetAperture() {
            this.$axios.get(this.$settings.BASE_URL_CMS + 'CMS-KM/Brightness/GetApertureFNumber/').then((res) => {
                if (res.data.code == 100) {
                    console.log(res.data.data, 99999999999)
                    this.I29.aperture = res.data.data
                    this.GetApertureFNumberList()
                }
            })
        }
        ,
        // 获取设备测量模式的列表
        GetMeasurementSetupList() {
            this.GetAutoAdjustExposure()
            this.GetLensFocusDistanceRange()
            this.GetExposureTimeTrue()
            this.GetLensFocusDistance()
            this.GetConoscopeCalibrationID()
            this.GetImageScalingCalibrationID()
            this.GetFlatFieldID()
        }
        ,
        // 获取是否自动曝光
        GetAutoAdjustExposure() {
            this.$axios.get(this.$settings.BASE_URL_CMS + 'CMS-KM/Brightness/GetExposure/').then((res) => {
                if (res.data.code == 100) {
                    this.GetAutoAdjust = res.data.data
                    this.I29.autoExposure = res.data.data
                    if (res.data.data == true) {
                        this.GetFixedExposureTime()
                    }
                }
            })
        }
        ,
        // 获取设备固定曝光时间
        GetFixedExposureTime() {
            this.$axios.get(this.$settings.BASE_URL_CMS + 'CMS-KM/Brightness/GetFixedExposureTime/').then((res) => {
                if (res.data.code == 100) {
                    this.GetExposureTime = res.data.data
                    this.I29.exposure_time = res.data.data
                }
            })
        }
        ,
        GetCaptureFilterState() {
            this.$axios.get(this.$settings.BASE_URL_CMS + 'CMS-KM/Brightness/GetCapture/').then((res) => {
                if (res.data.code == 100) {
                    this.IS_FILTER_TYPE_Y_GREEN = res.data.data['FILTER_TYPE_Y_GREEN']
                    this.IS_FILTER_TYPE_X_RED = res.data.data['FILTER_TYPE_X_RED']
                    this.IS_FILTER_TYPE_Z_BLUE = res.data.data['FILTER_TYPE_Z_BLUE']
                    this.IS_FILTER_TYPE_XB = res.data.data['FILTER_TYPE_XB']
                    this.is_filter_state_red = res.data.data['FILTER_TYPE_X_RED']
                    this.is_filter_state_green = res.data.data['FILTER_TYPE_Y_GREEN']
                    this.is_filter_state_blue = res.data.data['FILTER_TYPE_Z_BLUE']
                    this.is_filter_state_xx = res.data.data['FILTER_TYPE_XB']

                }
            })
        }
        ,
        // 获取当前曝光模式
        GetExposureLimitId() {
            this.$axios.get(this.$settings.BASE_URL_CMS + 'CMS-KM/Brightness/GetExposure/').then((res) => {
                if (res.data.code == 100) {
                    this.I29.SetExposureLimit_id = this.SetExposureLimit[res.data.data]
                    this.I29.GetImageScalingID = res.data.data
                }
            })

        },
        // 获取当前所有滤镜的使用状态
        GetExposureTimeTrue() {
            this.$axios.get(this.$settings.BASE_URL_CMS + 'CMS-KM/Brightness/GetExposureTime/').then((res) => {
                if (res.data.code == 100) {
                    this.FILTER_TYPE_Y_GREEN = res.data.data['FILTER_TYPE_Y_GREEN']
                    this.FILTER_TYPE_X_RED = res.data.data['FILTER_TYPE_X_RED']
                    this.FILTER_TYPE_Z_BLUE = res.data.data['FILTER_TYPE_Z_BLUE']
                    this.FILTER_TYPE_XB = res.data.data['FILTER_TYPE_XB']
                    this.I29.filter_state_red = res.data.data['FILTER_TYPE_X_RED']
                    this.I29.filter_state_green = res.data.data['FILTER_TYPE_Y_GREEN']
                    this.I29.filter_state_blue = res.data.data['FILTER_TYPE_Z_BLUE']
                    this.I29.filter_state_xb = res.data.data['FILTER_TYPE_XB']
                }
            })
        }
        ,
        // 获取镜头焦距的范围
        GetLensFocusDistanceRange() {
            this.$axios.get(this.$settings.BASE_URL_CMS + 'CMS-KM/Brightness/GetLensFocus/').then((res) => {
                if (res.data.code == 100) {
                    this.LensFocalLengthMin = res.data.data['LensFocalLengthMin']
                    this.LensFocalLengthMax = res.data.data['LensFocalLengthMax']
                }
            })
        }
        ,
        // 获取当前的镜头焦距
        GetLensFocusDistance() {
            this.$axios.get(this.$settings.BASE_URL_CMS + 'CMS-KM/Brightness/GetLensFocusDistance/').then((res) => {
                if (res.data.code == 100) {
                    this.GetLensFocalLength = res.data.data
                    this.I29.focus_distance = res.data.data
                }
            })
        }
        ,
        // 获取锥光镜头的信息列表
        GetConoscopeCalibrationList() {
            this.$axios.get(this.$settings.BASE_URL_CMS + 'CMS-KM/Brightness/GetCONOScope/').then((res) => {
                if (res.data.code == 100) {
                    this.GetConoscope = res.data.data
                    this.GetConoscopeCurrentValues = res.data.data[this.GetConoscopeCurrent]

                }
            })
        }
        ,
        // 获取当前设备的锥光镜头校正
        GetConoscopeCalibrationID() {
            this.$axios.get(this.$settings.BASE_URL_CMS + 'CMS-KM/Brightness/GetCONOScopeNumber/').then((res) => {
                if (res.data.code == 100) {
                    this.GetConoscopeCurrent = res.data.data
                    this.GetConoscopeCalibrationList()
                }
            })
        }
        ,
        // 获取图像标尺校准信息
        GetImageScalingCalibrationList() {
            this.$axios.get(this.$settings.BASE_URL_CMS + 'CMS-KM/Brightness/GetImageScalingCalibration/').then((res) => {
                if (res.data.code == 100) {
                    console.log(res.data.data)
                    this.GetImageScaling = res.data.data
                    this.I29.image_rulers = res.data.data[this.GetImageScalingID2]
                }
            })
        }
        ,
        // 获取当前设备的图像标尺校准
        GetImageScalingCalibrationID() {
            this.$axios.get(this.$settings.BASE_URL_CMS + 'CMS-KM/Brightness/GetImageScalingCalibrationNumber/').then((res) => {
                if (res.data.code == 100) {
                    this.GetImageScalingID2 = res.data.data
                    this.GetImageScalingCalibrationList()
                }
            })
        }
        ,
        // 获取均匀场校准信息
        GetFlatFieldCalibrationList() {
            this.$axios.get(this.$settings.BASE_URL_CMS + 'CMS-KM/Brightness/GetFlatField/').then((res) => {
                if (res.data.code == 100) {
                    this.GetFlatField = res.data.data
                    console.log(this.GetFlatFieldId, 8888)
                    console.log(res.data.data)
                    this.I29.homogeneous_field = res.data.data[this.GetFlatFieldId]
                }
            })
        }
        ,
        // 获取均匀场校准ID
        GetFlatFieldID() {
            this.$axios.get(this.$settings.BASE_URL_CMS + 'CMS-KM/Brightness/GetFlatFieldNumber/').then((res) => {
                if (res.data.code == 100) {
                    this.GetFlatFieldId = res.data.data
                    this.GetFlatFieldCalibrationList()
                }
            })
        }
        ,
        createI29() {
            this.is_createI29 = true
        }
        ,
        createI29_one() {

            this.$axios.post(this.$settings.BASE_URL_CMS + 'brightness_auto/i29create/', {
                name_file: this.I29.name_file,
                is_exposure: this.I29.autoExposure,
                filter_state_red: this.I29.filter_state_red,
                filter_state_green: this.I29.filter_state_green,
                filter_state_blue: this.I29.filter_state_blue,
                filter_state_xb: this.I29.filter_state_xb,
                is_filter_state_red: this.is_filter_state_red,
                is_filter_state_green: this.is_filter_state_green,
                is_filter_state_blue: this.is_filter_state_blue,
                is_filter_state_xb: this.is_filter_state_xx,
                focus_distance: this.I29.focus_distance,
                aperture: this.I29.aperture,
                color_calibration_id: this.I29.color_calibration_id,
                color_calibration_value: this.I29.color_calibration_value,
                color_shiftCorrection_id: this.I29.color_shiftCorrection_id,
                color_shiftCorrection_value: this.I29.color_shiftCorrection_value,
                SetExposureLimit_id: this.GetImageScalingID,
                SetExposureLimit_value: this.I29.SetExposureLimit_id,
                txt_type: this.I29.txt,
                FlatFieldCalibrationList_id: this.GetFlatFieldId,
                FlatFieldCalibrationList_value: this.I29.homogeneous_field,
                is_color: this.is_color,
                ImageScalingCalibration_id: this.GetImageScalingID2,
                ImageScalingCalibration_value: this.I29.image_rulers,
                ConoscopeCalibration_id: this.GetConoscopeCurrent,
                ConoscopeCalibration_value: this.GetConoscopeCurrentValues
            }).then((res) => {
                if (res.data.code == 100) {
                    this.is_createI29 = false
                    this.I29.name_file = ''
                    this.$notify({
                        title: res.data.msg,
                        type: 'success'
                    });
                } else {
                    this.$notify.error({ title: res.data.msg });
                }
            }
            ).catch(error => {
                this.$notify.error({ title: error });
            }
            );
        }
        ,
        handleClose_is_createI29(done) {
            this.$confirm('确认关闭？')
                .then(_ => {
                    done();
                })
                .catch(_ => {
                });
        }
        ,
        handleClose_is_address(done) {
            this.$confirm('确认关闭？')
                .then(_ => {
                    done();
                })
                .catch(_ => {
                });
        }
        ,

        connectDevice() {
            // 实现连接设备的逻辑
        }
        ,
        captureImage() {
            // 实现拍摄图像的逻辑
        }
        ,
        saveData() {
            // 实现保存数据的逻辑
        }
        ,
        setExposure() {
            // 实现设置曝光的逻辑
        }
        ,
    }
    ,
};
</script>
<style lang="less">
#I29 {
    height: 93%;
    overflow: auto;

    background-color: #161D26;

    .ititle {

        // margin: 0;
        margin: @h*30vh @w*20vw;
        padding: @h*20vh @w*20vw;
        width: @w*700vw;
        text-align: left;
        font-size: @h*30vh;
        border-bottom: 1px solid #909399;
        float: left;

    }

    .custom-heading {

        padding: @h*20vh @w*20vw;
        width: @w*700vw;
        text-align: left;
        font-size: @h*30vh;

        float: left;
    }

    .custom-box {
        padding: @h*10vh @w*20vw;
        width: @w*700vw;
        text-align: left;
        font-size: @h*30vh;
        // display: flex;
        float: left;

        .custom_list {
            width: @w*300vw;
            float: left;
            margin: @h*5vh @w*20vw;
            ;
        }

        label {
            margin-left: @w*5vw;
            font-size: @h*28vh;
        }

        .el-input {

            .el-input__inner {
                height: @h*50vh;
                background-color: #161D26;
                color: #fff;
                text-align: center;
            }
        }

        button {
            // margin-top: -10vh *@h;
            margin: 0 @w*10vw;
            ;
            height: @h*30vh;
            background-color: #161D26;
            color: #fff;
        }
    }
}
</style>
